#!/bin/bash
#

#设置变量
read -p "请输入主库的IP: " ip
read -p "请输入主库的端口: " port
#输出内容
PID=`redis-cli -h $ip -p $port info Server | awk -F: '/^process_id/{print $2}'`

CPU=`redis-cli -h $ip -p $port info CPU | awk -F: '/^used_cpu_sys_/{print $2}'`

MEMORY=`redis-cli -h $ip -p $port info Memory | awk -F: '/^used_memory:/{print $2}'`
#let sum=$((MEMORY/1024))
INPUT=`redis-cli -h $ip -p $port info Server | awk -F: '/^process_id/{print $2}'`
OUTPUT=`redis-cli -h $ip -p $port info Server | awk -F: '/^process_id/{print $2}'`

RECE=`redis-cli -h $ip -p $port info Server | awk -F: '/^process_id/{print $2}'`
PRO=`redis-cli -h $ip -p $port info Server | awk -F: '/^process_id/{print $2}'`

INBUFF=`redis-cli -h $ip -p $port info Clients | awk -F: '/input_buffer/{print $2}'`
OUTBUFF=`redis-cli -h $ip -p $port info Clients | awk -F: '/output_buffer/{print $2}'`

echo "PID:$PID
CPU:${CPU}内存:${MEMORY} 
接收的连接:${INPUT}拒绝的连接:${OUTPUT}
网卡流入流量:${RECE}网卡流出流量:${PRO}
缓存命中:${INBUFF}丢失:${OUTBUFF}
" | sed 's|\r||g'


